package com.xhu.service.impl;

import com.xhu.mapper.GameMapper;
import com.xhu.pojo.Game;
import com.xhu.pojo.User;
import com.xhu.pojo.UserGameRel;
import com.xhu.service.GameService;
import com.xhu.utils.ResponseMessage;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class GameServiceImpl implements GameService {
    @Resource
    private GameMapper gameMapper;

    @Resource
    private RedisTemplate<String, User> redisTemplate;

    @Override
    public ResponseMessage gameListByUserId(String userId) {
        List<Game> gameList= gameMapper.gameListByUserId(userId);
        return new ResponseMessage(200,"course list",gameList);
    }

    @Override
    public ResponseMessage deleteUserGameRel(Integer userId,Integer gameId) {
        gameMapper.deleteUserGameRel(userId,gameId);
        return new ResponseMessage(200,"delete success");
    }

    @Override
    public ResponseMessage allGameList() {
        List<Game> gameList=gameMapper.allGameList();
        return new ResponseMessage(200,"all course list",gameList);
    }

    @Override
    public ResponseMessage addGameByUser(UserGameRel userGameRel) {
        gameMapper.addGameByUser(userGameRel.getUserId(),userGameRel.getGameId());
        return new ResponseMessage(200,"insert success");
    }
}
